/**********************************************************************************
// Asteroids Race 
//
// Creation:	13 Out 2009
// Updated:		18 Apr 2011
// Compiler:	Visual Studio 2010
//
// Notes:		GameComplete
//
**********************************************************************************/

#include "Asteroids.h"

/**********************************************************************************/

void Asteroids::GameCompleteLogic()
{
	 
	// H Key 
	if (input.KeyPressRelease(DIK_H))
	{
		// exiting sound
		snd.Play(TRANSITION,0);

		// entering level music/sound
		snd.Play(INTRO,1);

		// go to next level
		gameState = HOME;			
	}
}

/**********************************************************************************/

void Asteroids::GameCompleteDraw()
{
	// draw finish marker
	if (playerOverall < (overallRecord + 5.0f))
	{
		// green
		finish.color = Color(0,255,0);
		finish.Draw();
	}
	else if (playerOverall < (overallRecord + 10.0f))
	{
		// yellow
		finish.color = Color(255,255,0);
		finish.Draw(); 
	}
	else
	{
		// red
		finish.color = Color(185,0,0);
		finish.Draw();
	}

	// Draw Text
	sprintf_s(text, "GAME COMPLETE");
	sysFont->Draw(0, midY-128, text, Color(0,255,0), GetWindowWidth(), 30, DT_CENTER);

	// record time
	sprintf_s(text, "00:%06.3f", overallRecord);
	sysFont->Draw(0, midY-5, text, Color(0,255,0), GetWindowWidth(), 30, DT_CENTER);


	// if player set a new overall record
	if (playerOverall < overallRecord)
	{
		sprintf_s(text, "New Overall Record");
		sysFont->Draw(0, midY-88, text, Color(0,255,0), GetWindowWidth(), 30, DT_CENTER);

		// player time
		sprintf_s(text, "00:%06.3f", playerOverall);
		sysFont->Draw(0, midY-63, text, Color(0,255,0), GetWindowWidth(), 30, DT_CENTER);

		sprintf_s(text, "Previous Overall Record");
		sysFont->Draw(0, midY-25, text, Color(0,255,0), GetWindowWidth(), 30, DT_CENTER);
	}
	else if (playerOverall < (overallRecord + 5.0f))
	{
		sprintf_s(text, "Your Overall Time");
		sysFont->Draw(0, midY-88, text, Color(0,255,0), GetWindowWidth(), 30, DT_CENTER);

		// player time
		sprintf_s(text, "00:%06.3f", playerOverall);
		sysFont->Draw(0, midY-63, text, Color(0,255,0), GetWindowWidth(), 30, DT_CENTER);

		sprintf_s(text, "Best Overall Time");
		sysFont->Draw(0, midY-25, text, Color(0,255,0), GetWindowWidth(), 30, DT_CENTER);
	}
	else if (playerOverall < (overallRecord + 10.0f))
	{
		sprintf_s(text, "Your Overall Time");
		sysFont->Draw(0, midY-88, text, Color(255,255,0), GetWindowWidth(), 30, DT_CENTER);

		// player time
		sprintf_s(text, "00:%06.3f", playerOverall);
		sysFont->Draw(0, midY-63, text, Color(255,255,0), GetWindowWidth(), 30, DT_CENTER);

		sprintf_s(text, "Best Overall Time");
		sysFont->Draw(0, midY-25, text, Color(0,255,0), GetWindowWidth(), 30, DT_CENTER);
	}
	else
	{
		sprintf_s(text, "Your Overall Time");
		sysFont->Draw(0, midY-88, text, Color(185,0,0), GetWindowWidth(), 30, DT_CENTER);

		// player time
		sprintf_s(text, "00:%06.3f", playerOverall);
		sysFont->Draw(0, midY-63, text, Color(185,0,0), GetWindowWidth(), 30, DT_CENTER);

		sprintf_s(text, "Best Overall Time");
		sysFont->Draw(0, midY-25, text, Color(0,255,0), GetWindowWidth(), 30, DT_CENTER);
	}

	// theoretical best time
	sprintf_s(text, "Theoretical Best");
	sysFont->Draw(0, midY+30, text, Color(0,255,0), GetWindowWidth(), 30, DT_CENTER);

	sprintf_s(text, "(Sum of Level Records)");
	sysFont->Draw(0, midY+50, text, Color(0,255,0), GetWindowWidth(), 30, DT_CENTER);

	sprintf_s(text, "00:%06.3f", theoreticalBest);
	sysFont->Draw(0, midY+70, text, Color(0,255,0), GetWindowWidth(), 30, DT_CENTER);


	sprintf_s(text, "<H> - Home Screen");
	sysFont->Draw(0, GetWindowHeight()-30, text, Color(128,128,128), GetWindowWidth(), 30, DT_CENTER);
}

/**********************************************************************************/